Skip to content

fix: parse the full /proc/self/maps pathname in check_nccl_so - #779

Open
li-lizhe wants to merge 1 commit into
deepseek-ai:mainfrom
li-lizhe:fix/nccl-deleted-mapping-parse
Open

li-lizhe wants to merge 1 commit into
deepseek-ai:mainfrom
li-lizhe:fix/nccl-deleted-mapping-parse

Conversation

@li-lizhe

Copy link
Copy Markdown

Fixes #777.

check_nccl_so() identifies the mapped NCCL library with line.strip().split(' ')[-1], which is the last space-separated token, not the pathname field of /proc/self/maps:

  • a pathname that contains a space is truncated, so the wrong file is handed to filecmp.cmp();
  • a mapping whose backing inode was replaced or removed is reported with a trailing (deleted) marker, so the token is literally (deleted) and the check dies with
FileNotFoundError: [Errno 2] No such file or directory: '(deleted)'

That is the traceback in #777: it aborts the import long before any NCCL version comparison happens, and hides the actual condition.

Change (deep_ep/__init__.py, +19/-1)

  • Read the pathname field (sixth field) of each /proc/self/maps line instead of the last token.
  • Strip the (deleted) marker and raise an explicit AssertionError naming the library and the likely cause (the NCCL library changed underneath a running process, e.g. a concurrent pip install) instead of surfacing a bare FileNotFoundError.
  • The duplicate-runtime and version-comparison logic is unchanged.

Verification

The real check_nccl_so() is extracted from both revisions by AST and executed against synthetic /proc/self/maps content (filecmp.cmp and glob stubbed with a fixed file set; stdlib only, no torch / NCCL import needed):

case before after
plain pathname returns normally returns normally
pathname containing a space FileNotFoundError: 'nccl/lib/libnccl.so.2' returns normally
(deleted) mapping FileNotFoundError: '(deleted)' AssertionError: The NCCL library mapped as /root/nccl/lib/libnccl.so.2 was replaced or removed while it was still mapped ...
two different libnccl mappings duplicate-runtime AssertionError duplicate-runtime AssertionError (unchanged)

Not tested: an actual import deep_ep / check_nccl_so() run on a machine with NCCL and a GPU (no such environment was available, so the version-comparison path against a real loaded library is exercised only through the stubbed harness above).

Signed-off-by: li-lizhe 147392333@qq.com

check_nccl_so() identified the mapped NCCL library with
line.strip().split(' ')[-1]. A pathname that contains a space, or that
Linux reports with the ' (deleted)' suffix after the underlying inode was
replaced/removed, made that expression yield a truncated path or the
literal '(deleted)'. filecmp.cmp() then raised a bare FileNotFoundError
instead of a useful NCCL diagnosis.

Parse the sixth field of /proc/self/maps (the full pathname) and turn a
deleted mapping into an explicit, actionable error.

Signed-off-by: li-lizhe <147392333@qq.com>
@li-lizhe

Copy link
Copy Markdown
Author

Gentle ping on this one — it's been quiet for 7 days since the last activity, so I wanted to check whether there's anything else you'd like me to adjust or add before this can move forward. Happy to make changes if so. Thanks!

@li-lizhe li-lizhe closed this Oct 31, 2026
@li-lizhe li-lizhe reopened this Oct 31, 2026
@li-lizhe

Copy link
Copy Markdown
Author

@LyricZhao @jershi425 — would one of you be able to take a look at this when you get a chance?

/proc/self/maps pathname is truncated or wrong

check_nccl_so takes the last space-separated token as the library path. That breaks on paths containing spaces, and on a replaced or removed mapping it hands (deleted) to the comparison and raises a bare FileNotFoundError instead of a real diagnosis. This parses the sixth field properly and reports the deleted case explicitly.

Happy to adjust if the approach doesn't fit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] check_nccl_so treats /proc/self/maps '(deleted)' suffix as filename and raises FileNotFoundError

1 participant